import rclpy
from rclpy.node import Node
from geometry_msgs.msg import TransformStamped
from tf2_ros import StaticTransformBroadcaster
rclpy.init()
# node = Node('transform_node')
# pub = StaticTransformBroadcaster(node)
# t = TransformStamped()
# t.header.stamp = node.get_clock().now().to_msg()
# t.header.frame_id = 'B'
# t.child_frame_id = 'C'
# t.transform.translation.x = 0.0
# t.transform.translation.y = 0.0
# t.transform.translation.z = 3.0

# t.transform.rotation.x = 1.0
# t.transform.rotation.y = 0.0
# t.transform.rotation.z = 0.0
# t.transform.rotation.w = 0.0

# pub.sendTransform(t)


node2 = Node('transform_node2')
tf_pub = StaticTransformBroadcaster(node2)
t2 = TransformStamped()
t2.header.stamp = node2.get_clock().now().to_msg()
t2.header.frame_id = 'C'
t2.child_frame_id = 'O'
t2.transform.translation.x = 2.0
t2.transform.translation.y = 1.0
t2.transform.translation.z = 2.0

t2.transform.rotation.x = 1.0
t2.transform.rotation.y = 0.0
t2.transform.rotation.z= 0.0
t2.transform.rotation.w = 0.0

def sent_transform():
    t2.header.stamp = node2.get_clock().now().to_msg()
    tf_pub.sendTransform(t2)
node2.create_timer(0.1,sent_transform)
rclpy.spin(node2)